<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.w3.org/1999/xhtml">

<head>
	<meta charset="utf-8">
	<meta name="viewport"
		  content="width=device-width, initial-scale=1.0, maximum-scale=1.0">

<title>369Pay</title>
<meta name="keywords" content="369Pay系统">
<meta name="description" content="369Pay系统">
	<link href="/css/style.css" rel="stylesheet">
	<link href="/css/login/style.css" rel="stylesheet">
	<link href="/css/login.css" rel="stylesheet">
	<!--[if lt IE 9]>
	<meta http-equiv="refresh" content="0;ie.html" />
	<![endif]-->
	<script>
        if (window.top !== window.self) {
            window.top.location = window.location;
        }
	</script>
	<style type="text/css">
		label.error{
			margin-left: 35px;
			color: #fc5f54;
		}
		input:-webkit-autofill, textarea:-webkit-autofill, select:-webkit-autofill{
			background-color: revert !important;
			background-image: none !important;
		}
	</style>

</head>

<body>
	<div class="head">
		<div class="head_con"><div class="logo1"><img id="logo" height="59" src="/img/login/369.jpg"></div> <div class="logo2">
			<span>客服电话：888-8888-8888</span>
		</div></div>
	</div>
	<div class="content1">
		<div class="signinpanel">
			<div class="col-sm-5 col-md-offset-8">
				<form id="signupForm">
					<p class="m-t-md text-center lc1">369云支付系统</p>
					<input type="text" name="username" class="form-control uname" maxlength="20"/>
					<input type="password" name="password"	class="form-control pword m-b" maxlength="20"/>
					<i class="btn btn-login btn-block lbtn">登录</i>
				</form>
			</div>
		</div>
	</div>
	<div class="footer" style="margin: 0;">
		<p class="foot_font" style="color: white;"> &copy; 2019 All Rights By 369Pay </p>
	</div>
	<div  th:include="include :: common-footer"></div>
	<script type="text/javascript">
		$(document).ready(function() {
			validateRule();
            $(".lbtn").click(function () {
                debugger;
                var flag = $("#signupForm").valid();
                if(flag){
                    submitFunc();
                }
            });
		});
		$.validator.setDefaults({
			submitHandler : submitFunc
		});

		function submitFunc(){
            var username = $("#signupForm input[name='username']").val();
            var password = $("#signupForm input[name='password']").val();
            $.ajax({
                type : "POST",
                url : "/salt",
                data:{username:username},
                success : function(r) {
                    if (r.code == 0) {
                        login(username,md5(username+md5(password)+r.data));
                    } else {
                        layer.msg(r.msg);
                    }
                }
            })
		}

		function login(username,password) {
			$.ajax({
				type : "POST",
				url : "/login",
				data : {
					username:username,
					password:password
				},
				success : function(r) {
					if (r.code == 0) {
						parent.location.href = '/index';
					} else {
						layer.msg(r.msg);
					}
				}
			});
		}

		function validateRule() {
			var icon = "<i class='fa fa-times-circle'></i> ";
			$("#signupForm").validate({
				rules : {
					username : {
						required : true
					},
					password : {
						required : true
					}
				},
				messages : {
					username : {
						required : icon + "请输入您的用户名",
					},
					password : {
						required : icon + "请输入您的密码",
					}
				}
			})
		}
	</script>
</body>
</html>
